//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101
//#include "stdafx.h"
#include "BackwardFlat.h"
using namespace Cephei::QL::Math::Interpolations;
#include <gen/QL/Math/Interpolation.h>
using namespace Cephei::QL::Math;
#undef HANDLE
#undef ABSTRACT
#undef STRUCT
Cephei::QL::Math::Interpolations::CBackwardFlat::CBackwardFlat (boost::shared_ptr<QuantLib::BackwardFlat>& childNative, Object^ owner) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phBackwardFlat = NULL;
#endif
	_ppBackwardFlat = &childNative;
    
}
Cephei::QL::Math::Interpolations::CBackwardFlat::CBackwardFlat (QuantLib::BackwardFlat& childNative, Object^ owner) 
{
#ifdef HANDLE
	_phBackwardFlat = NULL;
#endif
	_ppBackwardFlat = new boost::shared_ptr<QuantLib::BackwardFlat> (&childNative);
    
    _BackwardFlatOwner = owner;
    
}

Cephei::QL::Math::Interpolations::CBackwardFlat::CBackwardFlat (CBackwardFlat^ copy) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phBackwardFlat = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppBackwardFlat = new boost::shared_ptr<QuantLib::BackwardFlat> (copy->GetShared());
        
    }
}
Cephei::QL::Math::Interpolations::CBackwardFlat::CBackwardFlat (System::Type^ t) 
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phBackwardFlat = NULL;
#endif
	if (!t->IsSubclassOf(CBackwardFlat::typeid))
		throw gcnew Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Math::Interpolations::CBackwardFlat::CBackwardFlat (QuantLib::Handle<QuantLib::BackwardFlat>& childNative, Object^ owner)  
{
	_pSpinlock = new boost::detail::spinlock ();
	_phBackwardFlat = &childNative;
	_ppBackwardFlat = &static_cast<boost::shared_ptr<QuantLib::BackwardFlat>>(childNative.currentLink());
    
    _BackwardFlatOwner = owner;
}
Cephei::QL::Math::Interpolations::CBackwardFlat::CBackwardFlat (QuantLib::Handle<QuantLib::BackwardFlat> childNative)  
{
	_pSpinlock = new boost::detail::spinlock ();
	_phBackwardFlat = &childNative;
	_ppBackwardFlat = &static_cast<boost::shared_ptr<QuantLib::BackwardFlat>>(childNative.currentLink());
    
}
#endif
#ifdef STRUCT
Cephei::QL::Math::Interpolations::CBackwardFlat::CBackwardFlat (QuantLib::BackwardFlat childNative)  
{
	_pSpinlock = new boost::detail::spinlock ();
#ifdef HANDLE
	_phBackwardFlat = NULL;
#endif
	_ppBackwardFlat = new boost::shared_ptr<QuantLib::BackwardFlat> (new QuantLib::BackwardFlat (childNative));
    
}
#endif

Cephei::QL::Math::Interpolations::CBackwardFlat::~CBackwardFlat ()
{
	if (_pSpinlock != NULL)
    {
        delete _pSpinlock;
        _pSpinlock = NULL;
    }
    if (_ppBackwardFlat != NULL)
    {
	    delete _ppBackwardFlat;
        _ppBackwardFlat = NULL;
    }
}
Cephei::QL::Math::Interpolations::CBackwardFlat::!CBackwardFlat ()
{
	if (_pSpinlock != NULL)
    {
        delete _pSpinlock;
    }
    if (_ppBackwardFlat != NULL)
    {
	    delete _ppBackwardFlat;
    }
}
QuantLib::BackwardFlat& Cephei::QL::Math::Interpolations::CBackwardFlat::GetReference ()
{
    if (_ppBackwardFlat == NULL) throw gcnew NativeNullException ();
	return **_ppBackwardFlat;
}
boost::shared_ptr<QuantLib::BackwardFlat>& Cephei::QL::Math::Interpolations::CBackwardFlat::GetShared ()
{
    if (_ppBackwardFlat == NULL) throw gcnew NativeNullException ();
	return *_ppBackwardFlat;
}
QuantLib::BackwardFlat* Cephei::QL::Math::Interpolations::CBackwardFlat::GetPointer ()
{
    if (_ppBackwardFlat == NULL) throw gcnew NativeNullException ();
	return &**_ppBackwardFlat;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::BackwardFlat>& Cephei::QL::Math::Interpolations::CBackwardFlat::GetHandle ()
{
	if (_phBackwardFlat == NULL)
	{
		_phBackwardFlat = new Handle<QuantLib::BackwardFlat> (*_ppBackwardFlat);
	}
	return *_phBackwardFlat;
}
#endif
bool Cephei::QL::Math::Interpolations::CBackwardFlat::HasNative () 
{
	return (_ppBackwardFlat != NULL);
}

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

